<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>后台管理系统</title>
	    <meta name="author" content="BaiYY"/>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	    <meta name="renderer" content="webkit">
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
	</head>
	<body>
		<div class="right-sidebar" style="max-width: 1200px;">
			<ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist">
		        <li role="presentation"><a href="{:U('Admin/Main/buy')}">购买{:L('GAME_RESOURCE')}</a></li>
		        <li role="presentation" class="active"><a href="#">订单确认</a></li>
		    </ul>
		
		    <notempty name='allow_buy'>
		        <div class="alert alert-warning" role="alert">对不起，您无权限购买!</div>
		        <else/>
		        <div class="row">
		            <div class="col-md-3">
		                <div class="panel panel-default text-center">
		                    <div class="panel-body">
		                        <p><span class="label label-info">{$result.goods_name}</span></p>
		                        <p><span>{:L('GAME_RESOURCE')}数量：</span>{$result.number} {$result.unit}</p>
		                        <p><span>商品价格：</span>{$result.price} 元</p>
		                    </div>
		                </div>
		
		                <div>
		                    <p style="color:#19a97b;font-weight:bold;"><span style="width:120px;">应付金额：</span><span>{$result.price} 元</span></p>
		                    <input type="hidden" id="goods_id" value="{$result.goods_id}">
		                    <button type="submit" class="btn btn-primary center-block" id="submit">购买</button>
		                </div>
		            </div>
		        </div>
		    </notempty>
			<div id="imgData">
				<input type="hidden" value="{:L('GAME_SHOWPIC')}" >
				<p style="margin-top: 10px;">以下可进行二维码支付，支付完成后请务必通知管理员</p>
				<div>
					<img src="__PUBLIC__/admin/img/1.jpg" alt="微信支付">
					<img src="__PUBLIC__/admin/img/2.jpg" alt="支付宝支付">
					<img src="__PUBLIC__/admin/img/3.jpg" alt="微信添加">
				</div>
			</div>
		</div>
		<script type="text/javascript">
			$(function(){
			    var showImg = $.trim($("#imgData>input").val());
			    if(showImg == '' || showImg == 'GAME_SHOWPIC') {
			        $("#imgData").remove();
				}
				$("#submit").click(function(){
					var goods_id = $("#goods_id").val();
					var url = "{:U('Admin/Main/buySave')}?goods_id=" + goods_id;
					$.ajax({
						type:"post",
						url:url,
						timeout: 5000,
						dataType:"json",
						data: {},
						success:function(data){
							if(data == 'success'){
								alert('申请成功，请等待审核！');
								window.location.href="{:U('Admin/Main/buyList')}";
							}else if(data == 'error') {
								alert('申请失败！');
							}
						},
						complete: function (XMLHttpRequest, status) {
		                    if (status == "timeout") {
		                        alert(TIPS.TIMEOUT);
		                    }
		                }
					});
				})
			});
		</script>
	</body>
</html>
